package com.zhuoya.healthcard.net;

import android.util.Log;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import okhttp3.logging.HttpLoggingInterceptor;

/**
 * @Author: guolinguang
 * @Date: 2020/4/10 15:57
 * @Description: http拦截器
 **/
public class HttpLogger implements HttpLoggingInterceptor.Logger {
    @Override
    public void log(String message) {
        //判断是不是UTF-8
        String encode = "UTF-8";
        if (message.contains("http")) {
            try {
                Log.d("HTTP", URLDecoder.decode(message, "UTF-8"));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }else {
            Log.d("HTTP", message);
        }

    }
}
